﻿using System;
using System.IO;
using System.Net;

namespace Vkontakte.Api
{
	public interface IVkApiAutorizationMethod
	{
		int AppID { get; set; }
		ApplicationAccess ApplicationAccess { get; set; }
		bool IsAuthorized { get; }
		Session GetAuthorizationToken();
		void Authenticate();

		event Action NeedLoginData;
		event Action Authenticated;
		event Action LoginCanceled;
	}



	//public sealed class ApiAuthorizator
	//    : IVkApiAutorizationMethod
	//{
	//    private int _appID;
	//    private ApplicationAccess _applicationAccess;

	//    public int AppID
	//    {
	//        get { return _appID; }
	//        set { _appID = value; }
	//    }

	//    public ApplicationAccess ApplicationAccess
	//    {
	//        get { return _applicationAccess; }
	//        set { _applicationAccess = value; }
	//    }

	//    public bool IsAuthorized
	//    {
	//        get { throw new NotImplementedException(); }
	//    }

	//    public Session GetAuthorizationToken()
	//    {
	//        throw new NotImplementedException();
	//    }

	//    public void Authenticate()
	//    {
	//        string url = Utils.GetLoginUri(AppID, ApplicationAccess);
	//        HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create( url );
	//        request.BeginGetResponse( this.ResponseCallback, request );
	//    }

	//    private void ResponseCallback( IAsyncResult ar )
	//    {
	//        HttpWebRequest request = ( HttpWebRequest ) ar.AsyncState;
	//        try
	//        {
	//            WebResponse response = request.EndGetResponse(ar);
	//            Stream s= response.GetResponseStream();
	//            StreamReader r = new StreamReader( s );
	//            string str= r.ReadToEnd();
	//        }
	//        catch ( Exception )
	//        {
				
	//        }
			
	//    }


	//    public event Action NeedLoginData;

	//    public event Action Authenticated;

	//    public event Action LoginCanceled;
	//}
}